package com.zhuang.io2.work;

import java.io.*;

public class HomeWork01 {
	public static void main(String[] args) throws IOException {
		String dirPath = "f:\\mytemp";
		File file = new File(dirPath);
		if (!file.exists()) {
			if (file.mkdirs()) {
				System.out.println("创建" + dirPath + "成功");
			} else {
				System.out.println("创建" + dirPath + "失败");
			}
		}

		String filePath = dirPath + "\\hello.txt";
		file = new File(filePath);
		if (!file.exists()) {
			if (file.createNewFile()) {
				System.out.println(filePath + "创建成功");
				BufferedWriter bw = new BufferedWriter(new FileWriter(file));
				bw.write("哈哈哈！！！");
				bw.close();
			} else {
				System.out.println(filePath + "创建失败");
			}
		} else {
			System.out.println("文件已经存在");
		}
	}
}
